using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Q.Framework.Extension
{
    public enum FormatDateTime { Date, DateTime, InvertedDateTime, InvertedDate }

    public static class DateTimeExtension
    {
        public static String Format(this DateTime value, FormatDateTime type)
        {
            if (value == DateTime.MinValue || value == new DateTime(1900, 1, 1))
                return String.Empty;

            switch (type)
            {
                case FormatDateTime.Date: return value.ToString("dd/MM/yyyy");
                case FormatDateTime.DateTime: return value.ToString("dd/MM/yyyy HH:mm:ss");
                case FormatDateTime.InvertedDate: return value.ToString("yyyyMMdd");
                case FormatDateTime.InvertedDateTime: return value.ToString("yyyyMMddHHmmss");
            }

            return String.Empty;
        }

        public static Boolean IsDefaultValue(this DateTime value)
        {
            return value == new DateTime(1900, 1, 1) || value == DateTime.MinValue;
        }
    }
}